package com.example.search.dao;

import com.example.search.model.Shop;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

/**
 * @Auther: nanhuanh
 * @Date: 2019/3/6 16:03
 * @Description:
 */
@Repository
public interface ShopRepository extends ElasticsearchRepository<Shop, String> {

    @Query("{ \"query\" : { \"match\" : { \"shopName\" : \"?0\" }}}")
    Page<Shop> findByShopName(String shopName, Pageable pageable);

    @Query("{ \"query\" : { \"match\" : { \"shopCode\" : \"?0\" }}}")
    Page<Shop> findByShopCode(String shopCode, Pageable pageable);

    Page<Shop> findByIsOpen(int isOpen, Pageable pageable);


}
